package com.hc.ssm.controller;

import com.hc.ssm.feign.IMemberCommonFeign;
import com.hc.ssm.feign.IMemberFeign;
import com.hc.ssm.pojo.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private IMemberFeign iMemberFeign;

    @Autowired
    private IMemberCommonFeign iMemberCommonFeign;

    @RequestMapping("getOrder")
    public String getOOrder() {
        String forObject = restTemplate.getForObject("http://APP-HAOCHENIT-MEMBER/getMember", String.class);
        return "订单调用会员系统:" + forObject;
    }

    @RequestMapping("getOrderFeign")
    public String getOrderFeign() {
        return "订单调用会员系统:" + iMemberCommonFeign.getMember();
    }

    @RequestMapping("getMemberList")
    public List<Member> getMemberList() {
        return iMemberFeign.getMemberList();
    }

    @RequestMapping("/getMemberById")
    public String getMemberById(Integer id) {
        System.out.println("------------------" + id + "---------------");
       return iMemberFeign.getMemberById(id);
    };

    @RequestMapping("/addMember")
    public void addMember(Member member) {
        System.out.println("------------------" + member + "---------------");
        iMemberFeign.addMember(member);
    };

    @RequestMapping("/getMemberById2")
    public Member getMemberById2(Integer id) {
        System.out.println("------------------" + id + "---------------");
        return iMemberFeign.getMemberById2(id);
    };
}
